package com.lagou.edu.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyUtil {

    private static final Properties PROPERTIES = new Properties();

    public static final String MARK = ",";

    static {
        InputStream inputStream = PropertyUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
        try {
            PROPERTIES.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Properties getProperties() {
        return PROPERTIES;
    }

    public static String getProperty(String name) {
        return PROPERTIES.getProperty(name);
    }

    public static String[] getBasePackage() {
        String property = PROPERTIES.getProperty("base.package");
        if (property.contains(MARK)) {
            return property.split(MARK);
        }
        return new String[]{property};
    }
}
